#include <stdio.h>
#include <stdbool.h>

void fastsort(int* num,int start,int end)
{
    int left=start;
    int right=end;
    int temp=num[left];
    while(left<right)
    {
        while(left<right&&num[right]>temp)
        {
            right--;
        }
        if(left<right)
        {
            num[left]=num[right];
            left++;
        }
        while(left<right&&num[left]<temp)
        {
            left++;
        }
        if(left<right)
        {
            num[right]=num[left];
            right--;
        }
        num[left]=temp;
    }
    fastsort(num,start,left-1);
    fastsort(num,right+1,end);
}

bool containsDuplicate(int* nums, int numsSize) {
    fastsort(nums,0,numsSize-1);
    if(numsSize==1)
    return false;
    if(nums[0]==nums[1])
    return true;
    if(nums[numsSize-1]==nums[numsSize-2])
    return true;
    for(int i=1;i<numsSize-1;i++)
    {
        if(nums[i]==nums[i+1]&&nums[i]==nums[i-1])
        return true;
    }
    return false;
}

int main(int argc,char* argv[])
{
    int a[10]={1,1,1,3,3,4,3,2,4,2};
    bool x=containsDuplicate(a,10);
    for(int i=0;i<10;i++)
    printf("%d ",a[i]);
    printf("\n");
    printf("%d\n",x);
    return 0;
}